package service;

import java.util.ArrayList;
import java.util.List;

import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.ccc.model.Orderinfo;
import com.ccc.model.User;
import com.ccc.service.OrderinfoService;
import com.ccc.service.UserService;

public class OrderinofServiceTest {
	
	private static UserService userService;
	private static OrderinfoService o;


	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		try {
			ApplicationContext cxt = new ClassPathXmlApplicationContext("beans.xml");
			o = (OrderinfoService)cxt.getBean("orderinfoService");
			userService = (UserService)cxt.getBean("userService");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@Test
	public void outcome(){
		List<Orderinfo> list = new ArrayList<Orderinfo>();
		
		Orderinfo orderinfo1 = new Orderinfo();
		orderinfo1.setId(1);
		orderinfo1.setDeliverCount(5);
		Orderinfo orderinfo2 = new Orderinfo();
		orderinfo2.setId(2);
		orderinfo2.setDeliverCount(5);
		Orderinfo orderinfo3 = new Orderinfo();
		orderinfo3.setId(3);
		orderinfo3.setDeliverCount(5);
		
		list.add(orderinfo1);
		list.add(orderinfo2);
		list.add(orderinfo3);
		User user = userService.findUser(3);
		o.outcome(list, 2, user);
	}
	

}
